package Parser;

import model.Dimension;
import model.SGrid;

import org.jdom2.Element;

public class GenerateSGrid {

	public GenerateSGrid(ParserJDOM parserJDOM, SGrid sGrid) {

		parserJDOM.resetRoot();

		Element element = parserJDOM.searchElement("SGrid");
		sGrid.setColsNumber(Integer.valueOf(element.getChild("colsNumber")
				.getValue()));
		sGrid.setRowsNumber(Integer.valueOf(element.getChild("rowsNumber")
				.getValue()));

		Element element2 = parserJDOM.searchElement("scorePanelDimension");
		Dimension dimension1 = new Dimension();
		dimension1.setRow(Integer.valueOf(element2.getChild("row").getValue()));
		dimension1.setColumn(Integer.valueOf(element2.getChild("column")
				.getValue()));
		dimension1.setHeight(Integer.valueOf(element2.getChild("height")
				.getValue()));
		dimension1.setWidth(Integer.valueOf(element2.getChild("width")
				.getValue()));

		parserJDOM.setCurrent(element);
		Element element3 = parserJDOM.searchElement("deathPanelDimension");
		Dimension dimension2 = new Dimension();
		dimension2.setRow(Integer.valueOf(element3.getChild("row").getValue()));
		dimension2.setColumn(Integer.valueOf(element3.getChild("column")
				.getValue()));
		dimension2.setHeight(Integer.valueOf(element3.getChild("height")
				.getValue()));
		dimension2.setWidth(Integer.valueOf(element3.getChild("width")
				.getValue()));

		sGrid.setScorePanelDimension(dimension1);
		sGrid.setDeathPanelDimension(dimension2);

	}
}
